import { createPage } from '@mpxjs/core'

createPage({
  data: {
    showMask: false,
    showRule: false,
    title: '专属城市天际线场景'
  },
  onLoad() {
    const nav = this.selectComponent('.nav')
    nav.setData({
      canPageBack: true
    })
    this.getNavStyle()
  },
  methods: {
    getNavStyle() {
      const systemInfo = wx.getWindowInfo()
      const menuInfo = wx.getMenuButtonBoundingClientRect()

      const navStyle = {
        width: menuInfo.left - (systemInfo.windowWidth - menuInfo.right),
        height: menuInfo.height,
        marginTop:
          systemInfo.statusBarHeight +
          menuInfo.top -
          systemInfo.statusBarHeight,
        marginBottom: menuInfo.top - systemInfo.statusBarHeight
      }
      this.setData({
        navStyle
      })
    },
    pageBack() {
      wx.navigateBack()
    },
    go(e) {
      const city = e.currentTarget.dataset.index
      wx.navigateTo({
        url: `../../pages/snap/snap?city=${city}`
      })
    }
  }
})
